#include "MainGraphicsScene.h"

#include <QGraphicsLineItem>
#include <QPen>
#include <QString>
#include <QGraphicsView>

CMainGraphicsScene::CMainGraphicsScene(QObject * parent):QGraphicsScene(parent) 
{
}

CMainGraphicsScene::~CMainGraphicsScene(void)
{
}

void CMainGraphicsScene::drawLines()
{

		//QString area = "X = " +QString::number(this->views().at(0)->sceneRect().x()) +" Y = "+this->views().at(0)->sceneRect().y()+" Width = "+this->views().at(0)->sceneRect().width()+" Height= "+this->views().at(0)->sceneRect().height();
	QGraphicsLineItem *lineItem; 
	
	int startHeight = 0;
	int startWidth = 0;

	int maxHeight = 1400;
	int maxWidth = 800;

	for (int x=startHeight;x<maxHeight;x = x +10)
	{
		lineItem = new QGraphicsLineItem();
		QPen pen(QColor(0,0,255));
		if(x==startHeight)
		{
			pen.setColor(QColor(255,0,0));
		}
		lineItem->setOpacity(0.2);
		if(x==0)
		{
			pen.setColor(QColor(0,255,0));
			lineItem->setOpacity(1);

		}

		lineItem->setPen(pen);
		lineItem->setLine(x,startWidth,x,maxWidth);
	//	lineItem->setLine(this->sceneRect().width()/2,this->sceneRect().height()/2,this->sceneRect().x()/2,this->sceneRect().y());
		

		this->addItem(lineItem);

	}

	for (int y=startWidth;y<maxWidth;y = y +10)
	{
		lineItem = new QGraphicsLineItem();
		QPen pen(QColor(0,0,255));
		if(y==startWidth)
		{
			pen.setColor(QColor(255,0,0));
		}
		lineItem->setOpacity(0.2);

		if(y==0)
		{
			pen.setColor(QColor(0,255,0));
			lineItem->setOpacity(1);

		}

		lineItem->setPen(pen);
		lineItem->setLine(startHeight,y,maxHeight,y);
	//	lineItem->setLine(this->sceneRect().width()/2,this->sceneRect().height()/2,this->sceneRect().x()/2,this->sceneRect().y());


		this->addItem(lineItem);

	}





		QString area = "X = " +QString::number(this->itemsBoundingRect().x()) +" Y = "+QString::number(this->itemsBoundingRect().y())+" Width = "+QString::number(this->itemsBoundingRect().width())+" Height= "+QString::number(this->itemsBoundingRect().height());
	this->addText(QString("NEW GRAPHICS SCENE : ") + area);

	//this->setSceneRect(this->itemsBoundingRect());


		lineItem = new QGraphicsLineItem();
		QPen pen(QColor(255,0,0));
		lineItem->setOpacity(1);
		lineItem->setPen(pen);
		lineItem->setLine(this->sceneRect().width()/2,0,this->sceneRect().width()/2,this->sceneRect().height());
	
		this->addItem(lineItem);


		lineItem = new QGraphicsLineItem();
		QPen pen1(QColor(255,0,0));
		lineItem->setOpacity(1);
		lineItem->setPen(pen1);
		lineItem->setLine(0,this->sceneRect().height()/2,this->sceneRect().width(),this->sceneRect().height()/2);
		
		this->addItem(lineItem);

}



